package com.homework.util;



import java.util.ArrayList;
import java.util.List;

import org.json.JSONObject;

import com.homework.bean.editor.MyHomework;
import com.homework.bean.editor.MyParagraphElement;
import com.homework.bean.editor.MySpanElement;
import com.homework.bean.editor.MyTextElement;

public class TxtToMyHomework {
	
	
	public static String txtToMyHomework(String txt){
		MyHomework h = new MyHomework();
		MyTextElement te = new MyTextElement();
		MyParagraphElement pe = new MyParagraphElement();
		MySpanElement se = new MySpanElement();
		se.setText(txt);
		List<Object> l = new ArrayList<Object>();
		l.add(se);
		pe.setSpanOr(l);
		List<Object> p = new ArrayList<Object>();
		p.add(pe);
		te.setPara(p);
		List<Object> t = new ArrayList<Object>();
		t.add(te);
		h.setTitle(t);
		JSONObject jo = new JSONObject(h);
		String ret = jo.toString();
		System.out.println(ret);
		return ret;
	}
	
	public static void main(String args[]){
		TxtToMyHomework.txtToMyHomework("zhouxiang");
	}
}
